<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta property="wb:webmaster" content="6fb2b4de5a6b35cc" />
<link rel="icon" 
      type="image/png" 
      href="../static/image/get32px.png">
  <title>风中骑士</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="../static/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="../static/css/app.css" type="text/css" >
  <link rel="stylesheet" href="../static/css/jdc.icon.css" type="text/css" >

  <link rel="stylesheet" type="text/css" href="static/css/index-btn.css">
  <script src="http://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"></script>
  <script src="../static/script/bootstrap.min.js"></script>
  <script src="../static/script/emojify.js"></script>
  <script src="../static/script/app.js"></script>
    


    </head>    
<body id="body">
   <div class="navbar navbar-fixed-top navbar-get" role="navigation" id="theheader">
      <div class="container clearfix">

          <a class="logo" href="../index.html"><span class="get">Meta</span>Blog</a>         
          <div class="navbar-collapse collapse pull-right">
          <ul class="get-cate-nav">
            <li class=" active "><a href="#">Home</a></li>
            <li class=""><a href="../me/meta.html">Whoami</a></li>
                 
          </ul>  
          </div>      
           <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;咱们蓝翔如果不踏踏实实学本事，那跟清华北大还有什么区别？—— by 蓝翔校长</p>    
      </div><!-- /.container -->
</div><!-- /.navbar -->   
 
    <div class="container">

      <div class="row row-offcanvas row-offcanvas-right">
        <div class="col-xs-12 col-sm-9">
            
<div class="get-article-area " id="gacontent">
<h1 class="green">Template</h1>
<p class="exp">by Meta</p>
    
 <div class="yue top20">
    <div>
<h2>函数模板</h2>
<pre><code>template&lt;class 类型参数1，class 类型参数2，...&gt;
返回值类型 模板名（形参表）
{
    函数体
}
eg:
交换两个变量值
template &lt;class T&gt;
void swap(T &amp;a,T &amp;b)
{
    T temp = x;
    x = y;
    y = temp;
}
</code></pre>

<p>1.函数模板可以重载，只要形参表不同即可</p>
<p><img src = "../static/image/template1.JPG"></p>
<h2>2.编译器</h2>
<p><img src = "../static/image/template2.JPG"></p>
<h2>类模板</h2>
<pre><code>template&lt;class 类型参数1，class 类型参数2，...&gt;
class 类模板名
{
    成员变量与成员函数
}；
</code></pre>

<p><img src="../static/image/template3.JPG"></p>
<h2>类模板与继承</h2>
<blockquote>
<p>类模板派生类模板 </br>
模板类(就是类模板中类型/非类型参数实例化后的类)派生类模板</br>
普通类派生类模板</br>
模板类派普通类</br></p>
</blockquote>
<p><img src="../static/image/template4.JPG"></p>
<h2>7/21/2014 7:28:00 PM</h2>
</div>
    	
    </p>
</div>   
    

    
    <ul class="get-article-actions">
        <li><a href="#">分享到微博</a></li>
        <li class="kblink-1607"><a href="#" >收藏到知识库</a></li>
        <li class="followlink-1"><a href="#">关注@Easy</a></li>
    </ul>
    </ul>
  
</div>

 <div class="get-user-menu">  
        <a href="#top" class="link">TOP</a></div> 
 
    </div><!--/.container-->


</body>
</html>
